<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>
<link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
<link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>


<body class="gray-bg">

<div class="ui-layout-west">
	<div class="main-content">
		<div class="box box-main">
			<div class="box-header">
				<div class="box-title">
					<i class="fa icon-grid"></i> 广播终端管理
				</div>
				<div class="box-tools pull-right">
					<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
					<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
					<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新"><i class="fa fa-refresh"></i></button>
				</div>
			</div>
			<div class="ui-layout-content">
				<div id="tree" class="ztree"></div>
			</div>
		</div>
	</div>
</div>

<div class="container-div ui-layout-center">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="user-form">
				<input type="hidden" id="aid" name="aid">
				<input type="hidden" id="tid" name="tid">
						<div class="select-list">
							<ul>
								<li>
									终端IMEI：<input type="text" name="tid"/>
								</li>
								<li>
									终端名称：<input type="text" name="tname"/>
								</li>
								<!--<li>-->
									<!--区域名称：<input type="text" name="aname"/>-->
								<!--</li>-->

								<!--<li>
									出厂编号：<input type="text" name="facid"/>
								</li>-->
								<!--<li>-->
									<!--安装地址：<input type="text" name="address"/>-->
								<!--</li>-->
								<!--<li>
									备注：<input type="text" name="note"/>
								</li>-->

								<!--<li>
									终端接入通信网：<input type="text" name="comstand"/>
								</li>-->

								<!--<li>
									终端接入广播电视网模式：<input type="text" name="broadtel"/>
								</li>-->

								<!--<li>-->
									<!--终端管理员名称：<input type="text" name="manager"/>-->
								<!--</li>-->

								<!--<li>-->
									<!--终端管理员电话：<input type="text" name="managertel"/>-->
								<!--</li>-->

								<!--<li>
									终端交互时间：<input type="text" name="intertime"/>
								</li>-->
								<!--<li>-->
									<!--创建时间：&lt;!&ndash;<input type="text" name="createdtime"/>&ndash;&gt;-->
                                        <!--<input name="createdtime" class="laydate-icon form-control layer-date"-->
                                               <!--id="broaddate" value="" readonly="readonly" style="width:120px;"-->
                                               <!--placeholder="创建时间" title="创建时间"/>-->
								<!--</li>-->
								<li>
									最后修改时间：<input type="text" name="lastaccesstime"/>
								</li>
								<!--<li>-->
									<!--是否可用：&lt;!&ndash;<input type="text" name="isuse"/>&ndash;&gt;-->
										<!--<input type="radio" name="isuse" value="1" style="width: 50px" checked="checked">是-->
										<!--<input type="radio" name="isuse" value="0" style="width: 50px">否-->
								<!--</li>-->
								<!--<li>
									终端号码：<input type="text" name="phone"/>
								</li>-->

								<!--<li>-->
									<!--RDS码：<input type="text" name="rds"/>-->
								<!--</li>-->

								<!--<li>
									调频接收频率(终端可收转广播频率 )：<input type="text" name="fmfrequency"/>
								</li>-->

								<!--<li>
									终端流量使用限制，单位MB：<input type="text" name="trafficlimit"/>
								</li>-->
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
			<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="broad:organization:add">
				<i class="fa fa-plus"></i> 添加
			</a>
			<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="broad:organization:edit">
				<i class="fa fa-edit"></i> 修改
			</a>
			<a class="btn btn-danger  btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="broad:organization:remove">
				<i class="fa fa-remove"></i> 删除
			</a>

			<input type="text" name="rdsNum" id="rdsNum" width="50px"/>
			<a class="btn btn-info btn-del disabled" onclick="rdsSet()">
				<i class="fa fa-cog"></i> RDS设置
			</a>

			<input type="text" name="fmfrequencyNum" id="fmfrequencyNum" width="50px"/>
			<a class="btn btn-warning btn-del disabled" onclick="fmfrequency()">
				<i class="fa fa-wifi"></i> 调频接收频率
			</a>

			<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="broad:organization:export">
				<i class="fa fa-download"></i> 导出
			</a>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" style="text-align: center" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>

<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/jquery.tips.js}"></script>
<script th:src="@{/js/views/addpglist/addpglist.js}"></script>
<script th:src="@{/js/plugins/layer/laydate/laydate.js}"></script>

<!--时间插件-->
<script>
    laydate({
        elem:"#broaddate",
        event:"focus"
    });
    laydate({
        elem:"#broaddate",
        event:"focus"
    });
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem:"#broad",
            type: 'time',
        });
    });
</script>
<script>
    $(document).ready(function(){$(".sortable-list").sortable({connectWith:".connectList"}).disableSelection()});
</script>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "broad/organization";

    $(function() {
        $('body').layout({ west__size: 185 });
        queryAreaList();
        queryAreaTree();
    });

    function queryAreaList() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                exportUrl: prefix + "/export",
				removeUrl: prefix + "/remove",
				rdsSetUrl: prefix + "/rdsSet",
                fmfrequencyUrl: prefix + "/fmfrequencySet",
                modalName: "终端管理",
                search: false,
                showExport: true,
                striped: true,
                pagination: true,
                pageSize: 10,
                columns: [{
                    checkbox: true
                },
					{
						field : 'tid',
						title : '终端IMEI',
						visible: true
					},
					{
						field : 'tname',
						title : '终端名称'
					},
					{
						field : 'aid',
						title : '区域编号'
					},
					{
						field : 'aname',
						title : '区域名称'
					},
                    {
                        field : 'uname',
                        title : '管理员姓名'
                    },
                    {
                        field : 'facid',
                        title : '出厂编号'
                    },
                    {
                        field : 'address',
                        title : '安装地址'
                    },
                    {
                        field : 'phone',
                        title : '手机号码'
                    },
//					{
//						field : 'lastaccesstime',
//						title : '最后访问时间'
//					},
					// {
					// 	field : 'userid',
					// 	title : '用户编号'
					// },
					{
						field : 'createdtime',
						title : '创建时间'
					},
					{
						field : 'note',
						title : '备注'
					},
					{
						field : 'comstand',
						title : '接入通信网'
					},
					{
						field : 'broadtel',
						title : '终端广播网模式'
					},
					{
						field : 'manager',
						title : '终端管理员'
					},
					{
						field : 'managertel',
						title : '管理员电话'
					},
					{
						field : 'intertime',
						title : '交互时间'
					},
					{
						field : 'rds',
						title : 'RDS码'
					},
					{
						field : 'fmfrequency',
						title : '调频接收频率'
					},
					{
						field : 'trafficlimit',
						title : '限制流量/MB'
					},
					{
						field : 'isused',
						title : '是否可用'
					}
					// ,
					// {
					// 	field : 'pic',
					// 	title : '安装地址图片'
					// }
					]
            };
        $.table.init(options);
    };

    function queryAreaTree()
    {
        var url = ctx + "broad/organization/treeData";
        var options = {
            url: url,
            expandLevel: 2,
            onClick : zOnClick
        };
        $.tree.init(options);

        function zOnClick(event, treeId, treeNode) {
            $("#aid").val(treeNode.id);
            $.table.search();
        }
    }

    $('#btnExpand').click(function() {
        $._tree.expandAll(true);
        $(this).hide();
        $('#btnCollapse').show();
    });

    $('#btnCollapse').click(function() {
        $._tree.expandAll(false);
        $(this).hide();
        $('#btnExpand').show();
    });

    $('#btnRefresh').click(function() {
        queryAreaTree();
    });
	function rdsSet() {
		var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
		if (rows.length == 0) {
			$.modal.alertWarning("请至少选择一条记录");
			return;
		}
		$.modal.confirm("确认要更加选中的" + rows.length + "条数据的RDS码吗?", function() {
			var url = $.table._option.rdsSetUrl;
			var rdsNumber = document.getElementById("rdsNum").value;
			var data = {"ids": rows.join(),"number": rdsNumber};
			$.operate.submit(url, "post", "json", data);
		});
	}

    function fmfrequency() {
        var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.confirm("确认要更加选中的" + rows.length + "条数据的频率吗?", function() {
            var url = $.table._option.fmfrequencyUrl;
            var fmfrequencyNumber = document.getElementById("fmfrequencyNum").value;
            var data = {"ids": rows.join(),"number": fmfrequencyNumber};
            $.operate.submit(url, "post", "json", data);
    });
}
</script>
</body>
</html>